// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UcDatabaseDiff.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   The uc database diff.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


namespace DbDiff.WinClient.Forms.DbItems
{
    using System.ComponentModel;
    using System.Data;
    using Common.DataAccess;
    using Common.Helper;
    using Common.Model;

    /// <summary>
    /// The uc database diff.
    /// </summary>
    public class UcDatabaseDiff : UcDbItemDiff
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UcDatabaseDiff"/> class.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        public UcDatabaseDiff(Databases data, string title)
        {
            this.InitializeComponent();
            this.Init();
            this.Data = data;
            this.Title = title;
        }

        /// <summary>
        /// The init.
        /// </summary>
        private void Init()
        {
            this.HeaderVisible = true;
            this.DetailsControl = new UcItemDiffProperties();

            this.Toolbar = null;
            this.CommandMenu = null;
        }

        #endregion Constructors

        #region Form view / data update

        /// <summary>
        /// The update form data.
        /// </summary>
        protected override void UpdateFormData()
        {
            this.LblHeader.Text = this.Title;
            ((UcItemDiffProperties)this.DetailsControl).SetData(
                ((Databases)this.Data).DatabaseLeft.GetRawDatatable(DatabaseObjectTypes.Database).Rows[0],
                ((Databases)this.Data).DatabaseRight.GetRawDatatable(DatabaseObjectTypes.Database).Rows[0], 
                ((Databases)this.Data).Diff);
        }

        #endregion Form view / data update

        #region SetData

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="data1">
        /// The data 1.
        /// </param>
        /// <param name="data2">
        /// The data 2.
        /// </param>
        /// <param name="diff">
        /// The diff.
        /// </param>
        public void SetData(DataRow data1, DataRow data2, DataSetDiff diff)
        {
            if (this.DetailsControl != null)
            {
                ((UcItemDiffProperties) this.DetailsControl).SetData(data1, data2, diff);
            }
        }

        #endregion SetData

        #region Designer generated code

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
            }

            base.Dispose(disposing);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        ///   the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {

        }

        #endregion
    }
}